package cn.yunhe.controller;

import cn.yunhe.entity.Product;
import cn.yunhe.service.ProductService;
import cn.yunhe.util.JsonUtil;
import cn.yunhe.util.Paganation;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 获取所   有的商品
 */
@WebServlet("/AllProductServlet")
public class AllProductServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ProductService productService=new ProductService();
        int pageNo=Integer.parseInt(req.getParameter("pageNo"));
        Paganation<Product> paganation=productService.getAllProduct(pageNo);
        JsonUtil.getJson(resp,paganation);

    }
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
